home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / Draw / Sources / DrawSel.h < prev    next >
Encoding:
Text File  |  1996-09-17  |  7.3 KB  |  231 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                DrawSel.h
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Author:                Henri Lamiraux
  7. //
  8. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #ifndef DRAWSEL_H
  13. #define DRAWSEL_H
  14.  
  15. // ----- Part Layer -----
  16.  
  17. #ifndef FWSELECT_H
  18. #include "FWSelect.h"
  19. #endif
  20.  
  21. // ----- OS Layer -----
  22.  
  23. #ifndef FWRECT_H
  24. #include "FWRect.h"
  25. #endif
  26.  
  27. #ifndef FWRECSHP_H
  28. #include "FWRecShp.h"
  29. #endif
  30.  
  31. //========================================================================================
  32. //    Forward Declarations
  33. //========================================================================================
  34.  
  35. class FW_CGraphicContext;
  36. class FW_CMouseEvent;
  37.  
  38. class CDrawPart;
  39. class CDrawFrame;
  40. class CSelectionIterator;
  41. class CDrawSelection;
  42. class CBaseShape;
  43.  
  44. class CDrawContent;
  45. class CDrawSelectionContent;
  46. class CDrawPublishLinkCollection;
  47.  
  48. //========================================================================================
  49. //    class CDrawSelection
  50. //========================================================================================
  51.  
  52. class CDrawSelection : public FW_CSelection
  53. {
  54. //----------------------------------------------------------------------------------------
  55. //    Initialization/Destruction
  56. //
  57. public:
  58.     FW_DECLARE_AUTO(CDrawSelection)
  59.  
  60.     CDrawSelection(Environment* ev, CDrawPart* drawPart);
  61.     virtual         ~CDrawSelection();
  62.     
  63. //----------------------------------------------------------------------------------------
  64. //    Inherited API
  65. //
  66. public:
  67.     virtual void        CloseSelection(Environment* ev);
  68.     virtual void        SelectAll(Environment* ev);
  69.     virtual FW_Boolean    IsEmpty(Environment* ev) const;
  70.     virtual void        ClearSelection(Environment* ev);
  71.     
  72.     virtual FW_CContent* GetSelectedContent(Environment* ev);
  73.     
  74.     virtual ODShape*    AcquireSelectionShape(Environment* ev, ODFacet* facet, FW_CFrame* frame);
  75.     virtual ODShape*    AcquireSelectionOutline(Environment* ev, ODFacet* facet, FW_CFrame* frame);
  76.     
  77.     virtual FW_Boolean    CanPasteAsLink(Environment* ev, ODPasteAsMergeSetting& setting, ODStorageUnit* su);
  78.     virtual FW_Boolean    IsSelectionLinkable(Environment* ev);
  79.     
  80.     virtual FW_Boolean    IsMouseInDraggableItem(Environment* ev, 
  81.                             FW_CFrame* frame,
  82.                             const FW_CMouseEvent& theMouseEvent, 
  83.                             FW_Boolean inBackground);
  84.  
  85.     virtual void        UpdateSelectionOnMouseDown(Environment* ev, 
  86.                             const FW_CMouseEvent& mouseEvent,
  87.                             ODFacet* embeddedFacet,
  88.                             FW_Boolean inEmbeddedFrameBorder,
  89.                             FW_Boolean inBackground);
  90.     
  91.     virtual FW_CLinkDestination* GetLinkDestination(Environment* ev, FW_Boolean& multipleLinks);
  92.  
  93. //----------------------------------------------------------------------------------------
  94. //    New API
  95. //
  96. public:
  97.     CBaseShape*     WhichHandle(Environment* ev, FW_CGraphicContext& gc, const FW_CPoint& mouse, short& whichHandle, FW_Fixed zoomFactor) const;
  98.     
  99.     void            RenderSelectionHandles(Environment* ev, FW_CGraphicContext& gc, FW_Fixed zoomFactor);
  100.     void            InvalidateSelectionHandles(Environment* ev, CDrawFrame* frame);
  101.     
  102.     void            RenderHandles(Environment* ev, CBaseShape* shape);
  103.     void            RenderAllHandles(Environment* ev, CDrawFrame* frame);
  104.     
  105.     void            AddToSelection(Environment* ev, CBaseShape* theShape, FW_Boolean renderHandles);
  106.     void            RemoveFromSelection(Environment* ev, CBaseShape* theShape, FW_Boolean renderHandles);
  107.  
  108.     void            OffsetSelection(Environment* ev, FW_Fixed xDelta, FW_Fixed yDelta);
  109.  
  110.     FW_Boolean        Resize(Environment* ev, const FW_CMouseEvent& theMouseEvent);    
  111.  
  112.     void            SelectWithRectangle(Environment* ev, const FW_CMouseEvent& theMouseEvent);
  113.  
  114.     FW_Boolean        GetSelectionPenSize(Environment* ev, FW_Fixed& penSize);
  115.  
  116.     FW_CPoint        CenterSelection(Environment* ev, FW_CFrame* scopeFrame);
  117.     
  118.     unsigned long    Count() const;
  119.     
  120.     // ----- Frozen state -----
  121.     FW_Boolean        HasFrozen() const;
  122.     FW_Boolean        HasNotFrozen() const;
  123.     void            SetFrozen(Environment* ev, FW_Boolean state);
  124.     
  125.     ODShape*        GetUpdateShape() const;
  126.     const FW_CRect&    GetDragRect() const;
  127.  
  128.     // ----- Anchor Shape -----
  129.     CBaseShape*        GetAnchorShape() const;
  130.     void            SetAnchorShape(CBaseShape* shape);
  131.  
  132.  
  133.     // ----- Linking -----
  134.     void             SelectionChanged(Environment* ev, ODUpdateID updateID);
  135.     void            DeleteSelection(Environment* ev);
  136.  
  137.     void            CalcCache(Environment* ev);
  138.  
  139. private:
  140.     
  141.     void            DoAdd(Environment* ev, CBaseShape *shape);
  142.     void            DoRemove(Environment* ev, CBaseShape *shape);
  143.         
  144. public:
  145.     void            ShapeAdded(Environment* ev, CBaseShape* shape);
  146.     void            SelectContent(Environment* ev, CDrawContent* content);
  147.     CDrawContent*    GetDrawContent(Environment* ev);
  148.     CDrawPart*        GetDrawPart() const
  149.                         {return fDrawPart;}
  150.     CDrawPublishLinkCollection* GetSelectedLinkSources();
  151.  
  152.  
  153. //----------------------------------------------------------------------------------------
  154. //    Data Members
  155. //
  156. private:
  157.     CDrawPart*            fDrawPart;
  158.     FW_CRect            fDragRect;
  159.     ODShape*            fUpdateShape;
  160.     unsigned short        fFrozenCount;
  161.     unsigned long        fCount;
  162.     CBaseShape*            fAnchorShape;
  163.     short                fClickedHandle;
  164.     
  165.     CDrawSelectionContent*    fSelectionContent;
  166.     
  167.     FW_CRectShape        fWorkingHandle;
  168.     CDrawSelectionContent*    fDraggedContent;
  169. };
  170.  
  171. //========================================================================================
  172. //    CDrawSelection Inlines
  173. //========================================================================================
  174.  
  175. //----------------------------------------------------------------------------------------
  176. //    CDrawSelection::GetUpdateShape
  177. //----------------------------------------------------------------------------------------
  178. inline ODShape* CDrawSelection::GetUpdateShape() const
  179. {        
  180.     return fUpdateShape;
  181. }
  182.  
  183. //----------------------------------------------------------------------------------------
  184. //    CDrawSelection::GetDragRect
  185. //----------------------------------------------------------------------------------------
  186. inline const FW_CRect& CDrawSelection::GetDragRect() const
  187. {        
  188.     return fDragRect;
  189. }
  190.  
  191. //----------------------------------------------------------------------------------------
  192. //    CDrawSelection::HasFrozen
  193. //----------------------------------------------------------------------------------------
  194. inline FW_Boolean CDrawSelection::HasFrozen() const
  195. {
  196.     return fFrozenCount != 0;
  197. }
  198.  
  199. //----------------------------------------------------------------------------------------
  200. //    CDrawSelection::HasNotFrozen
  201. //----------------------------------------------------------------------------------------
  202. inline FW_Boolean CDrawSelection::HasNotFrozen() const
  203. {
  204.     return fCount != 0 && fFrozenCount != fCount;
  205. }
  206.  
  207. //----------------------------------------------------------------------------------------
  208. //    CDrawSelection::Count
  209. //----------------------------------------------------------------------------------------
  210. inline unsigned long CDrawSelection::Count() const
  211. {
  212.     return fCount;
  213. }
  214.  
  215. //----------------------------------------------------------------------------------------
  216. //    CDrawSelection::GetAnchorShape
  217. //----------------------------------------------------------------------------------------
  218. inline CBaseShape* CDrawSelection::GetAnchorShape() const
  219. {
  220.     return fAnchorShape;
  221. }
  222.  
  223. //----------------------------------------------------------------------------------------
  224. //    CDrawSelection::SetAnchorShape
  225. //----------------------------------------------------------------------------------------
  226. inline void CDrawSelection::SetAnchorShape(CBaseShape* shape)
  227. {
  228.     fAnchorShape = shape;
  229. }
  230.  
  231. #endif